var st = this.getStore('DeviceMaintainStore');
if (st.getCount() === 0 && Ext.isEmpty(st.getModifiedRecords())) {
    Ext.Msg.show({
        title: T.label.save,
        msg: T.msg.no_data_can_be_saved,
        icon: Ext.Msg.ERROR,
        buttons: Ext.Msg.OK
    });

    return;
}

var me = this;
var vResId = this.getItem('grdDeviceResource').getSelectionModel().getSelection()[0].get('resId');
var dtl = [];
Ext.each(st.getModifiedRecords(),
function(item) {
    var data = Ext.clone(item.data);
    data.resId = vResId;
    if (!data.noticeFlag || data.noticeFlag === "false") {
        data.noticeFlag = 'N';
    } else {
        data.noticeFlag = 'Y';
    }
    dtl.push(data);
});

Ext.Msg.show({
    title: button.getText(),
    msg: T.msg.are_you_sure_to_delete_data,
    icon: Ext.Msg.QUESTION,
    buttons: Ext.Msg.YESNO,
    fn: function(btnId) {
        if ('yes' == btnId) {
            button.setDisabled(true);

            YX.ZbusRpc.request({
                module: 'SresSaveDeviceMaintainDetailService',
                params: {
                    detailList: dtl
                },
                showSuccess: true,
                callback: function() {
                    button.setDisabled(false);
                },
                success: function() {
                    st.commitChanges();
                }
            })
        }
    }
});